import {Dimensions, PixelRatio, Platform, NativeModules} from 'react-native';
import DeviceInfo from 'react-native-device-info';
import Config from "react-native-config";

const {width, height, scale} = Dimensions.get('window');

export const DrawerWidth = 616;

export const HOTUPDATE = (Config.HOT_UPDATE == "1");

export const Const = {
    screenWidth: width,//屏幕宽
    screenHeight: height,//屏幕宽
    screenScale: scale,//屏幕分辨率
    onePixel: 1 / PixelRatio.get(),//一个像素尺寸
    isIos: Platform.OS === 'ios',
    isAndroid: Platform.OS === 'android',
    package: DeviceInfo.getBundleId,//包名(后台指定)
    pageCount: 10,
};

export const CodePushDeploymentKey = Config.CODE_PUSH_KEY_ANDROID;

function identifyDebugDevelopmentEnvironment() {
    try{
        const { scriptURL } = NativeModules.SourceCode
        if(scriptURL && scriptURL.length > 0) {
            const devSplit = scriptURL.split('&');
            if(devSplit.length > 1) {
                return devSplit[1] == 'dev=true';
            }
        }
        return false;
    }catch(error) {
    }
    return false;
}

export const SIMULATE_MODE = identifyDebugDevelopmentEnvironment();

